package app.aggr.domain;

import com.keter.framework.core.result.JSONResult;
import com.keter.framework.web.base.AbstractBaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class IndexController extends AbstractBaseController {
	private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

	@Autowired
	RestTemplate restTemplate;

	String SERVICE_NAME = "keter-service";

	@GetMapping("/")
	public JSONResult index() {
		return wrap("haha");
	}

	@GetMapping("/service")
	public JSONResult service() {
		return restTemplate.getForObject("http://"+SERVICE_NAME+"/",JSONResult.class);
	}

	@GetMapping("/service-1/sid")
	public JSONResult sid() {
		return restTemplate.getForObject("http://"+SERVICE_NAME+"/sid",JSONResult.class);
	}

	@GetMapping("/service-2/haha")
	public JSONResult haha() {
		return restTemplate.getForObject("http://"+SERVICE_NAME+"/sid",JSONResult.class);
	}
}
